function [Event_Rate_Structure] = Pull_Out_Event_Rate(Data_Summary, Row_Number)
%% Prep
Session1_Event_Rates(:,2) = Data_Summary(Row_Number).Session1_Event_Rates;
for n = 1:size(Session1_Event_Rates)
    Session1_Event_Rates(n,1) = n;
end
Session2_Event_Rates(:,2) = Data_Summary(Row_Number).Session2_Event_Rates;
for n = 1:size(Session2_Event_Rates)
    Session2_Event_Rates(n,1) = n;
end

a = size(Session1_Event_Rates,1);
b = size(Session2_Event_Rates,1);

if a - b == 1
    Session2_Event_Rates = cat(1, Session2_Event_Rates, [a,0]);
elseif b - a == 1
    Session1_Event_Rates = cat(1, Session1_Event_Rates, [b,0]);
elseif abs(a-b) ~= 1 && a>b
    Session2_Event_Rates = cat(1, Session2_Event_Rates, [(b+1:a)',zeros(a-b, 1)]);
elseif abs(a-b) ~= 1 && b>a
    Session1_Event_Rates = cat(1, Session1_Event_Rates, [(a+1:b)',zeros(b-a, 1)]);
else
    disp('both vectors have same size, good to go');
end

for n = 1:size(Session1_Event_Rates,1)
    if isnan(Session1_Event_Rates(n,2)) && isnan(Session2_Event_Rates(n,2))
        Session1_Event_Rates(n,1) = nan;
        Session2_Event_Rates(n,1) = nan;
    elseif isnan(Session1_Event_Rates(n,2)) && ~isnan(Session2_Event_Rates(n,2))
        Session1_Event_Rates(n,2) = 0;
    elseif ~isnan(Session1_Event_Rates(n,2)) && isnan(Session2_Event_Rates(n,2))
        Session2_Event_Rates(n,2) = 0;
    end
end

Session1_Event_Rates(isnan(Session1_Event_Rates)) = [];
Session1_Event_Rates = reshape(Session1_Event_Rates, [], 2);
Session2_Event_Rates(isnan(Session2_Event_Rates)) = [];
Session2_Event_Rates = reshape(Session2_Event_Rates, [], 2);


%%
Event_Rate_Structure_Original = struct(...
    'cell_ID', [], ...
    'session', Row_Number,...
    'genotype', Data_Summary(Row_Number).genotype,...
    'animal_ID', Data_Summary(Row_Number).animalName,...
    'expt_date', Data_Summary(Row_Number).dateToFind,...
    'drug', Data_Summary(Row_Number).drug,...
    'session1_dose', Data_Summary(Row_Number).session1_dose,...
    'session2_dose', Data_Summary(Row_Number).session2_dose,...
    'exptParadigm', Data_Summary(Row_Number).exptParadigm,...
    'session1_mobility_pass', Data_Summary(Row_Number).Mobility_Session1_Pass,...
    'session2_mobility_pass', Data_Summary(Row_Number).Mobility_Session2_Pass);
Event_Rate_Structure = Event_Rate_Structure_Original;
    

for n = 1:(size(Session1_Event_Rates,1)-1)
    Event_Rate_Structure = cat(1, Event_Rate_Structure, Event_Rate_Structure_Original);
end

for n = 1:size(Event_Rate_Structure,1)
    Event_Rate_Structure(n).cell_ID = Session1_Event_Rates(n,1);
    Event_Rate_Structure(n).Session1_Event_Rates = Session1_Event_Rates(n,2);
    Event_Rate_Structure(n).Session2_Event_Rates = Session2_Event_Rates(n,2);
end

end